package com.dongdongshop.result;

/**
 * 统一响应结果封装
 */
public class Result<T> {
    private Integer code;
    private String message;
    private T data;


    //根据传入的不同值，响应不同的结果
    public static Result jsonResponse(ResultEnum result){
        return new Result(result.getCode(),result.getValueCN());
    }
    public static Result jsonResponseInternational(ResultEnum result){
        return new Result(result.getCode(),result.getValueUS());
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result() {
    }

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public Result setData(T data) {
        this.data = data;
       return this;
    }
}
